package com.demo.config;

/**
 * author:王蒙蒙
 * date创建日期:2025/7/24
 * 类注释说明:
 **/


import java.io.InputStream;
import java.util.Properties;

public class ConfigLoader {
        private static final Properties properties = new Properties();

        static {
            try (InputStream input = ConfigLoader.class.getClassLoader().getResourceAsStream("api.properties")) {
                if (input != null) {
                    properties.load(input);
                } else {
                    throw new RuntimeException("api.properties file not found in classpath");
                }
            } catch (Exception e) {
                throw new RuntimeException("Failed to load api.properties", e);
            }
        }

        public static String getProperty(String key) {
            return properties.getProperty(key);
        }

        public static String getProperty(String key, String defaultValue) {
            return properties.getProperty(key, defaultValue);
        }

}
